package com.example.basic.encryp;

import java.io.*;
import java.util.Base64;

public class Base64Util {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String prefix = "https://safebrowsing.googleapis.com/v4/fullHashes:find?$req=";
        String suffix = "&$ct=application/x-protobuf";
        String targetUrl = "http://tanahsucikn.com/";

        // 使用基本编码
        String base64encodedString = Base64.getEncoder().encodeToString(targetUrl.getBytes("utf-8"));
        System.out.println("Base64 编码字符串 (基本) :" + base64encodedString);
        System.out.println("转化后的地址为 :" + (prefix + base64encodedString + suffix));
        System.out.println("---------------------------------------------------");
        base64encodedString = Base64.getUrlEncoder().encodeToString(targetUrl.getBytes("utf-8"));
        System.out.println("Base64 编码字符串 (URL) :" + base64encodedString);
        System.out.println("转化后的地址为 :" + (prefix + base64encodedString + suffix));
        System.out.println("---------------------------------------------------");

    }
}
